from ctypes import cdll, c_int, c_char_p

# 加载DLL
dll = cdll.LoadLibrary('./prime_check.dll')

# 设置函数原型
dll.is_prime.argtypes = [c_char_p]  # 参数类型是字符串指针
dll.is_prime.restype = c_int        # 返回值类型是整数

# 测试函数
test_numbers = [
    "2", "3", "4", "17", "100", "101",
    "1000000007", "123456789012345678901234567890123456789012345678901",
    "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999991"
]

for num in test_numbers:
    # 将字符串编码为utf-8字节串
    num_bytes = num.encode('utf-8')
    result = dll.is_prime(num_bytes)
    status = "prime" if result == 1 else "not prime" if result == 0 else "invalid input"
    print(f"{num} is {status}")
